Skip to content

chore: migrate mobile-crypto to BouncyCastle on Android#7461

Merged
diegolmello merged 7 commits into
developfrom
road-mosquito
Jul 3, 2026
Merged

chore: migrate mobile-crypto to BouncyCastle on Android#7461
diegolmello merged 7 commits into
developfrom
road-mosquito

Conversation

@diegolmello

@diegolmello diegolmello commented Jul 1, 2026

Copy link
Copy Markdown
Member

Proposed changes

Bumps the @rocket.chat/mobile-crypto dependency to the build that migrates the Android crypto implementation off the unmaintained SpongyCastle fork (com.madgag.spongycastle) onto BouncyCastle (org.bouncycastle:bcprov-jdk18on:1.84). The swap is mechanical — identical class names, no logic changes — and the library is only ever used as plain classes (never registered as a JCE provider), so there is no collision with Android's platform BouncyCastle namespace.

This PR is the consumer-side change only. It pins the dependency to the crypto commit adbcf7cde4469f31efe1d4bc72a98a0ced1b80f5 and refreshes the lockfiles:

  • package.json / pnpm-lock.yaml — repin @rocket.chat/mobile-crypto
  • ios/Podfile.lock — MobileCrypto 0.3.00.4.0

The upstream library change lives in RocketChat/rocket.chat-mobile-crypto#15.

Issue(s)

How to test or reproduce

E2E encryption exercises the migrated code paths (RSA OAEP/PKCS#1, PBKDF2). On both platforms:

  1. Build and run the app.
  2. Open an end-to-end encrypted room, send and receive messages, verify they decrypt correctly.
  3. Confirm existing encrypted history still reads (byte-compatibility with the previous SpongyCastle output).

The upstream PR verified byte-compatibility with a known-answer harness (31/31 fixed-vector KATs pass on Android API 36, expected values shared with iOS).

Screenshots

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

The dependency is pinned to a commit on the upstream feature branch rather than #main, because RocketChat/rocket.chat-mobile-crypto#15 is not yet merged. Before this can ship to develop, that PR should be merged and the pin moved back to the resulting #main commit. Note the upstream PR currently has red lint and test checks (unit tests are tracked separately in NATIVE-1378).

Summary by CodeRabbit

  • Bug Fixes
    • Improved Android build reliability by skipping Jetifier processing for a compatible dependency that could cause build failures.
    • Updated Android build settings so this compatibility rule is applied consistently during Android and E2E build workflows.
    • Excluded a problematic packaged manifest file to help prevent Android packaging issues.

Pin the mobile-crypto dependency to the commit that migrates the Android
implementation from the unmaintained SpongyCastle fork to BouncyCastle
(bcprov-jdk18on 1.84). Refreshes pnpm-lock.yaml and iOS Podfile.lock
(MobileCrypto 0.3.0 -> 0.4.0).
@diegolmello
diegolmello temporarily deployed to approve_e2e_testing July 1, 2026 20:37 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 052500f7-8a42-44f8-a861-edfec7549ce5

📥 Commits

Reviewing files that changed from the base of the PR and between 123607a and d652887.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • .github/workflows/e2e-build-android.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/e2e-build-android.yml
📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: E2E Build Android / android-build
  • GitHub Check: E2E Shard Preflight
  • GitHub Check: ESLint and Test / run-eslint-and-test
  • GitHub Check: format

Walkthrough

This PR adds bcprov-jdk18on to the Android Jetifier ignore list in gradle.properties, the build-android composite action, and the e2e-build-android workflow, and adds a packaging resources exclusion for an OSGi manifest file in android/app/build.gradle.

Changes

Android build configuration update

Layer / File(s) Summary
Add Jetifier ignorelist entry
android/gradle.properties, .github/actions/build-android/action.yml, .github/workflows/e2e-build-android.yml
Adds android.jetifier.ignorelist=bcprov-jdk18on to gradle.properties directly and via CI steps that write to it, to prevent Jetifier from processing the AndroidX-clean BouncyCastle dependency.
Exclude OSGi manifest from packaging
android/app/build.gradle
Adds android.packaging.resources exclusion for META-INF/versions/9/OSGI-INF/MANIFEST.MF, an unused multi-release jar manifest.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested labels: type: chore

Suggested reviewers: OtavioStasiak

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: switching the Android mobile-crypto path to BouncyCastle.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (2)
  • NATIVE-1284: Request failed with status code 401
  • NATIVE-1378: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Line 52: Keep the `@rocket.chat/mobile-crypto` dependency pinned to the current
RocketChat/rocket.chat-mobile-crypto#adbcf7cde4469f31efe1d4bc72a98a0ced1b80f5
reference in package.json and do not advance it until the upstream lint and test
checks are green. If this change is part of a version bump, revert only the
crypto dependency entry and preserve the existing pin so the app continues using
the known-good artifact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 444bfaee-9a97-45cb-a960-d9baa9522e01

📥 Commits

Reviewing files that changed from the base of the PR and between 20720c6 and 8f61e0d.

⛔ Files ignored due to path filters (2)
  • ios/Podfile.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • package.json
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: ESLint and Test / run-eslint-and-test
  • GitHub Check: format
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Prettier formatting with tabs, single quotes, 130 character line width, no trailing commas, and avoid arrow function parentheses

Files:

  • package.json
🧠 Learnings (2)
📚 Learning: 2026-02-05T13:55:00.974Z
Learnt from: Rohit3523
Repo: RocketChat/Rocket.Chat.ReactNative PR: 6930
File: package.json:101-101
Timestamp: 2026-02-05T13:55:00.974Z
Learning: In this repository, the dependency on react-native-image-crop-picker should reference the RocketChat fork (RocketChat/react-native-image-crop-picker) with explicit commit pins, not the upstream ivpusic/react-native-image-crop-picker. Update package.json dependencies (and any lockfile) to point to the fork URL and a specific commit, ensuring edge-to-edge Android fixes are included. This pattern should apply to all package.json files in the repo that declare this dependency.

Applied to files:

  • package.json
📚 Learning: 2026-05-07T17:47:14.516Z
Learnt from: diegolmello
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7303
File: package.json:5-5
Timestamp: 2026-05-07T17:47:14.516Z
Learning: When reviewing pnpm `packageManager` version pins in any `package.json` (e.g., `"packageManager": "pnpm@<version>"`), don’t rely solely on web-search results to determine whether a version exists. For very recently published versions, cross-check the target version against the official pnpm release page (https://github.com/pnpm/pnpm/releases) and the npm registry page for pnpm (https://www.npmjs.com/package/pnpm) before flagging the pinned version as non-existent.

Applied to files:

  • package.json

Comment thread package.json Outdated
"@rocket.chat/media-signaling": "1.0.0-rc.1",
"@rocket.chat/message-parser": "0.31.31",
"@rocket.chat/mobile-crypto": "RocketChat/rocket.chat-mobile-crypto#main",
"@rocket.chat/mobile-crypto": "RocketChat/rocket.chat-mobile-crypto#adbcf7cde4469f31efe1d4bc72a98a0ced1b80f5",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

commit='adbcf7cde4469f31efe1d4bc72a98a0ced1b80f5'

rg -n "$commit|MobileCrypto|`@rocket.chat/mobile-crypto`" package.json pnpm-lock.yaml ios/Podfile.lock

gh pr view 15 \
  --repo RocketChat/rocket.chat-mobile-crypto \
  --json state,mergeStateStatus,headRefOid,statusCheckRollup,url

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 3990


Hold this crypto pin until upstream is green. RocketChat/rocket.chat-mobile-crypto#adbcf7cde4469f31efe1d4bc72a98a0ced1b80f5 still has failing lint and test checks, so this encryption dependency is not yet backed by a clean upstream artifact.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` at line 52, Keep the `@rocket.chat/mobile-crypto` dependency
pinned to the current
RocketChat/rocket.chat-mobile-crypto#adbcf7cde4469f31efe1d4bc72a98a0ced1b80f5
reference in package.json and do not advance it until the upstream lint and test
checks are green. If this change is part of a version bump, revert only the
crypto dependency entry and preserve the existing pin so the app continues using
the known-good artifact.

bcprov-jdk18on:1.84 ships Java 25 multi-release classes that Jetifier's
bundled ASM cannot parse (Unsupported class file major version 69),
failing the release Kotlin compile of mobile-crypto. BouncyCastle is
already AndroidX-clean and needs no jetifying, so add it to the
jetifier ignorelist.
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

iOS Build Available

Rocket.Chat 4.75.0.109261

…dle.properties

CI regenerates android/gradle.properties from scratch (echo > ...), so the
android.jetifier.ignorelist entry committed to the checked-in file is
discarded for CI builds. Add it to both gradle.properties generators (the
build-android composite action and the e2e-build-android workflow) so the
release build can resolve bcprov-jdk18on:1.84 without Jetifier choking on
its Java 25 multi-release classes.
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

iOS Build Available

Rocket.Chat 4.75.0.109267

bcprov-jdk18on:1.84 and its transitive org.jspecify both bundle
META-INF/versions/9/OSGI-INF/MANIFEST.MF inside their multi-release jars,
so mergeReleaseJavaResource fails with a DuplicateRelativeFileException.
Exclude that OSGi bundle manifest (unused on Android) via a packaging block.
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

iOS Build Available

Rocket.Chat 4.75.0.109271

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

iOS Build Available

Rocket.Chat 4.75.0.109273

The mobile-crypto SpongyCastle to BouncyCastle change is a pure package
rename with no algorithm change and no JCE provider registration, so it
cannot alter crypto output. Re-running the pipeline to confirm the prior
E2E Run Android shard-3 (e2e-encryption) failure was environmental.

@OtavioStasiak OtavioStasiak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

iOS Build Available

Rocket.Chat 4.75.0.109284

# Conflicts:
#	.github/workflows/e2e-build-android.yml
@diegolmello
diegolmello temporarily deployed to approve_e2e_testing July 3, 2026 17:01 — with GitHub Actions Inactive
@diegolmello
diegolmello merged commit bd9fbd7 into develop Jul 3, 2026
10 checks passed
@diegolmello
diegolmello deleted the road-mosquito branch July 3, 2026 17:02
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

iOS Build Available

Rocket.Chat 4.75.0.109288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants